package com.first.agent.dao.impl;

import com.first.agent.dao.ReportDao;
import com.first.agent.dbutils.JdbcBuild;
import com.first.agent.pojo.AdvanceCharge;
import com.first.agent.pojo.AgentCustomer;
import com.first.agent.pojo.Product;
import com.first.agent.pojo.User;

import java.sql.SQLException;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ljc
 * Date: 2022/11/15 11:04
 * Description:
 * Version: V1.0
 */
public class ReportDaoImpl extends JdbcBuild implements   ReportDao {
    @Override
    public List<User> findAgentBalance(String start, String end) throws SQLException {
        String sql="select * from user where creation_time between ? and ? and u_ro_id = 1";
        Object[] params = {start,end};
        return super.queryListEntity(User.class,sql,params);
    }

    @Override
    public List<AdvanceCharge> findCharge(String start, String end) throws SQLException {
        String sql="select * from advance_charge where ad_time between ? and ? ";
        Object[] params = {start,end};
        return super.queryListEntity(AdvanceCharge.class,sql,params);
    }

    @Override
    public List<AdvanceCharge> findAgent(String start, String end) throws SQLException {
        String sql="select * from advance_charge where ad_time between ? and ? and agent_name = '韩璐'";
        Object[] params = {start,end};
        return super.queryListEntity(AdvanceCharge.class,sql,params);
    }

    @Override
    public List<Product> findProduct(String start, String end) throws SQLException {
        String sql="select pro_type,count(*) as count,sum(price) as price from product where pro_time between ? and ?" +
                "group by pro_type";
        Object[] params = {start,end};
        return super.queryListEntity(Product.class,sql,params);
    }
}
